package lynch.map 
{
	import flash.display.BitmapData;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;
	import lynch.Core.config.ration.Core.config.
	import starling.textures.SubTexture;
	import starling.textures.Texture;
	
	/**
	 * only open for WorldMap
	 * @author 小痛
	 */
	internal class MosaicMap 
	{
		private var texture:Texture;
		private var helpRect:Rectangle;
		private var tilesInV:int;
		private var tilesInH:int;
		
		public function MosaicMap() 
		{
			
		}
		
		/**
		 * update texture && helpRect && tilesInV && tilesInH
		 * @param	texture
		 * @param	ratio
		 * @param	tilesInV
		 * @param	tilesInH
		 */
		public function updateInfo(texture:Texture, ratio:Number, tilesInV:int, tilesInH:int):void
		{
			this.texture = texture;
			helpRect = new Rectangle(0, 0, Core.config.tileWidth * ratio, Core.config.tileHeight * ratio);
			
			this.tilesInV = tilesInV;
			this.tilesInH = tilesInH;
		}
		
		/**
		 * get mosaic texture
		 * @param	id
		 * @return
		 */
		public function getMTexture(id:int):Texture
		{
			helpRect.x = (id % tilesInV) >> 0;
			helpRect.y = (id / tilesInH) >> 0;
			
			return new SubTexture(texture, helpRect.clone());
		}
	}
}